<?php 
	//DB VERBINDUNG HERSTELLEN
	require_once('session.php');
	ob_start();
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
	<meta charset="utf-8" />
		
	<title>GamesLetsPlay</title>
	
	
	
	<link rel="stylesheet" href="style/960-grid-system.css" type="text/css">
	<link rel="stylesheet" href="style/style.css" type="text/css">
	<link rel="stylesheet" href="style/datepicker.css" type="text/css">
	<link rel="stylesheet" href="style/news.css" type="text/css">
	<link rel="stylesheet" href="style/profil.css" type="text/css">
	<link rel="stylesheet" href="style/message.css" type="text/css">
	
	<script type="text/javascript" src="js/jquery-1.8.2.min.js"></script>
    <script type="text/javascript" src="js/jquery-ui.js"></script>
    <script type="text/javascript" src="js/validate_password.js"></script>
    <script type="text/javascript" src="js/jquery.cookie.js"></script>
    <script type="text/javascript" src="js/jquery.tablesorter.js"></script>
	
	<script>
		jSonParseFunc = function(jsonString) {
			jsonObj = jQuery.parseJSON(jsonString);
			if(jsonObj.bool == true) {
				
				$('#messageBox').show();
				$('#messageBox').html(jsonObj.message);
				$('#userName').removeClass('inputFalse');
				$('#userPassword').removeClass('inputFalse');
				$('#messageBox').addClass('success');
				$("#messageBox").delay(3200).fadeOut(300);
				location.reload().delay(3200);
				
			}
			
			if(jsonObj.bool == false) {
				$('#messageBox').show();
				$('#messageBox').html(jsonObj.message);
				$('#userName').addClass('inputFalse');
				$('#userPassword').addClass('inputFalse');
				$('#messageBox').removeClass('success');
				$('#userName').val('');
				$('#userPassword').val('');
				$("#messageBox").delay(3200).fadeOut(300);
			}
		}
	
		$('#loginStart').live('click', function() {
			$('#loginShow').slideToggle('slow');
			$('#userName').removeClass('inputFalse');
			$('#userPassword').removeClass('inputFalse');
			$('#userName').val(''); 
			$('#userPassword').val('');
			$('#messageBox').hide();
			
		});
		
		$('#loginStart').live('hover', function() {
			$('#loginStart').toggleClass('selected');
		});
		
		$('#loginEnd').live('hover', function() {
			$('#loginEnd').toggleClass('selected');
		});
		
		$('#menuItem').live('hover', function() {
			$(this).toggleClass('selected');
		});
		
		$('#menuItem').live('click', function() {
			window.location = 'index.php?site='+$(this).html();
		});
		
		
		checkLogin = function(inputName, inputPassword) {
			$.post('login.php', {
				userName: inputName,
				userPassword: inputPassword
			}, function(data) {
				jSonParseFunc(data);
			});
		}
		
		destroySession = function(){
			$.post('session.php', {
				action: 'logout'
			}, function(data){
			window.location = 'index.php?site=Home';	
			});
			
		}
		
		checkPasswordStrength = function(password) {
			
			
			
			if(password.length < 6) {
				$(".pwStrength").removeClass('pwStrengthMedium');
				$(".pwStrength").removeClass('pwStrengthSecure');
				$(".pwStrength").removeClass('pwStrengthLow');
				$(".pwStrength").addClass('block');
				$(".pwStrength").html('Passwort muss mindestens 6 Zeichen lang sein <br>');
			}
			
			if(password.length >= 6) {
				$(".pwStrength").removeClass('pwStrengthMedium');
				$(".pwStrength").removeClass('pwStrengthSecure');
				$(".pwStrength").addClass('pwStrengthLow');
				$(".pwStrength").addClass('block');
				$(".pwStrength").html('Passwort Schwach<br>');
			}
			if(password.length >= 8) {
				
				$(".pwStrength").removeClass('pwStrengthLow');
				$(".pwStrength").removeClass('pwStrengthSecure');
				$(".pwStrength").addClass('pwStrengthMedium');
				$(".pwStrength").html('Passwort Mittel<br>');
			}
			if(password.length > 9) {
				
				$(".pwStrength").removeClass('pwStrengthMedium');
				$(".pwStrength").removeClass('pwStrengthLow');
				$(".pwStrength").addClass('pwStrengthSecure');
				$(".pwStrength").html('Passwort Stark<br>');
			}
			if(password.length < 3 && $(".pwStrength").html() != '<br>') {
				$(".pwStrength").html('<br>');
			}
		}
		
		checkRegForm = function(regName, regPass, regPassReenter, regEmail, regEmailReenter, regBirthDate){
			
			var checking = false;
			var errorMessages = '';
			
			<?php //Formularprüfung ob Felder leer sind ?>
			if(regName == ''){
				errorMessages ='<div id="errorName"> Benutzername darf nicht leer sein! </div>';
			} else {
				
				
			}
			
			if(regPass == ''){
				errorMessages += '<div id="errorPW"> Passwort darf nicht leer sein! </div>';
				
			} else {

			}
			
			if(regPassReenter == ''){
				errorMessages += '<div id="errorPWRE"> Passwort (Wiederholung) darf nicht leer sein! </div>';
				
			} else {
				if(regPassReenter != regPass){
					errorMessages += '<div id="errorPWRE"> Passw&ouml;rter stimmen nicht &uuml;berein! </div>';
				} else {
					checking = true;
				}
			}
			
			if(regEmail == ''){
				errorMessages += '<div id="errorEmail"> E-mail darf nicht leer sein! </div>';
				
			} else {
				
			}
			
			if(regEmailReenter == ''){
				errorMessages += '<div id="errorEmailReenter"> E-mail (Wiederholung) darf nicht leer sein! </div>';
				
			} else {
				if(regEmailReenter != regEmail){
					errorMessages += '<div id="errorPWRE"> E-Mails stimmen nicht &uuml;berein! </div>';
				} else {
					checking = true;
				}
			}
			
			if(regBirthDate == ''){
				errorMessages += '<div id="errorBD"> Geburtstag darf nicht leer sein! </div>';
				
			}
			
			
			<?php //Ausgabe der Fehler ?>
			
			if(checking == false && errorMessages != ''){
				$("#errorMessageForm").show('slow');
				$("#errorMessageForm").html(errorMessages);
			}
			
			if(checking == true && errorMessages == '') {
				$("#errorMessageForm").show('slow');
				$("#errorMessageForm").html('Hat alles geklappt');
			}
			
			
			<?php //Fehlermeldung nachfocus "hiden" ?>
			$("#registerName").live('focus', function(){
					$("#errorName").remove();
					
					if($("#errorMessageForm").html() == '') {
						$("#errorMessageForm").hide();
					}
			});
			
			$("#registerPassword").live('focus', function(){
					$("#errorPW").remove();
					if($("#errorMessageForm").html() == '') {
						$("#errorMessageForm").hide();
					}
			});
			
			$("#registerPasswordReenter").live('focus', function(){
					$("#errorPWRE").remove();
					
					if($("#errorMessageForm").html() == '') {
						$("#errorMessageForm").hide();
					}
			});
			
			$("#registerEmail").live('focus', function(){
					$("#errorEmail").remove();
					
					if($("#errorMessageForm").html() == '') {
						$("#errorMessageForm").hide();
					}
			});
			
			$("#registerEmailReenter").live('focus', function(){
					$("#errorEmailReenter").remove();
					if($("#errorMessageForm").html() == '') {
						$("#errorMessageForm").hide();
					}
			});
			
			$("#datepicker").live('focus', function(){
					$("#errorBD").remove();
					
					if($("#errorMessageForm").html() == '') {
						$("#errorMessageForm").hide();
					}
			});			
			
				
				 /*
				 regPass
				 regPassReenter
				 regEmail
				 regEmailReenter
				 regBirthDate
				*/
		}
		
    $(function() {
        $( "#datepicker" ).datepicker();
    });
	

	/*Profil Navigation collapse*/
	$(document).ready(function() {
// 1 COLUMN:
    // When the collapse button is clicked:
    $('.collapse').click(function() {
        $('.collapse').css("display","none");
        $('.expcolimage').css("display","block");
        $('#usercppms_e').css("display","block");
        $.cookie('leftCol', 'expanded');
    });
    // When the expand button is clicked:
    $('.expcolimage').click(function() {
        $('.expcolimage').css("display","none");
        $('.collapse').css("display","block");
        $('#usercppms_e').css("display","none");
        $.cookie('leftCol', 'collapsed');
    });
	
// 2 COLUMN:
    // When the collapse button is clicked:
    $('.collapse2').click(function() {
        $('.collapse2').css("display","none");
        $('.expcolimage2').css("display","block");
        $('#usercpprofile_e').css("display","block");
        $.cookie('rightMiddle', 'expanded');
    });
    // When the expand button is clicked:
    $('.expcolimage2').click(function() {
        $('.expcolimage2').css("display","none");
        $('.collapse2').css("display","block");
        $('#usercpprofile_e').css("display","none");
        $.cookie('rightMiddle', 'collapsed');
    });
	
// 3 COLUMN:
    // When the collapse button is clicked:
    $('.collapse3').click(function() {
        $('.collapse3').css("display","none");
        $('.expcolimage3').css("display","block");
        $('#usercpmisc_e').css("display","block");
        $.cookie('rightCol', 'expanded');
    });
    // When the expand button is clicked:
    $('.expcolimage3').click(function() {
        $('.expcolimage3').css("display","none");
        $('.collapse3').css("display","block");
        $('#usercpmisc_e').css("display","none");
        $.cookie('rightCol', 'collapsed');
    });	
	
// COOKIES
    // Left column state
    var leftCol = $.cookie('leftCol');
    // Middle column state
    var rightMiddle = $.cookie('rightMiddle');
    // Right column state
    var rightCol = $.cookie('rightCol');
    // Set the user's selection for the left column
    if (leftCol == 'collapsed') {
        $('.collapse').css("display","block");
        $('.expcolimage').css("display","none");
        $('#usercppms_e').css("display","none");
    };
    // Set the user's selection for the middle column
    if (rightMiddle == 'collapsed') {
        $('.collapse2').css("display","block");
        $('.expcolimage2').css("display","none");
        $('#usercpprofile_e').css("display","none");
    };
	// Set the user's selection for the right column
	if (rightCol == 'collapsed') {
        $('.collapse3').css("display","block");
        $('.expcolimage3').css("display","none");
        $('#usercpmisc_e').css("display","none");
    }; 
});
$(document).ready(function() 
    { 
        $("#myTable").tablesorter( {sortList: [[0,0], [1,0]]} ); 
    } 
); 
	
	</script>
	
</head>
<body>
                

<div id="header" class="container_12  headerLine">

<div id="headContent" class="grid_12" style="width: 100%;">
	<div class="mainMenu">
		<?php include('topMenu.php'); ?>
	</div>
		<div class="login">
			<?php if($_SESSION['user_id'] == 0): ?>
			<span id="loginStart"><span style="color: #FFFFFF">Zum Login</span></span>
			<div id="loginShow" class="loginContent">
				<form>
					<div class="loginContentFormat">
						<h1> Login</h1>
						<input type="text" id="userName" placeholder="Benutzername" autocomplete="off">
						<input type="password" id="userPassword" placeholder="Passwort" >
						<input type="button" value="Anmelden" onClick="checkLogin($('#userName').val(), $('#userPassword').val());" >
						<div id="messageBox" class="message"></div>
					</div>
				</form>
			</div>
			<?php else : ?>
			<span onCLick="destroySession();" id="loginEnd">Ausloggen</span>
			
			<?php endif; ?>
		</div>
</div>

</div>

                

<div id="content" class="container_12 mainPage">

<div id="" class="grid_8 mainContent">
<?php if(!isset($_GET['site'])): ?>
	<?php $_GET['site'] = 'Home'; ?>
<?php endif; ?>

<?php 
//admin//

if($rightId == 1)
{
	if(isset($_GET['site']) && ($_GET['site'] != 'Home' && $_GET['site'] != 'Nutzungsbedingungen' && $_GET['site'] != 'Registrieren' && $_GET['site'] != 'Forum' && $_GET['site'] != 'News' && $_GET['site'] != 'Administration' && $_GET['site'] != 'Calender' && $_GET['site'] != 'CalenderEdit' && $_GET['site'] != 'NewsEdit' && $_GET['site'] != 'Comments' && $_GET['site'] != 'NewsAdd' && $_GET['site'] != 'CommentsEdit' && $_GET['site'] != 'Cats' && $_GET['site'] != 'Profil' && $_GET['site'] != 'Datenschutz' && $_GET['site'] != 'Impressum' && $_GET['site'] != 'FAQ' && $_GET['site'] != 'Support')){
		include('errorPage.php');	
	}
		switch ($_GET['site']) {
		case "Home":
			include('home.php');
			break;
		case "Nutzungsbedingungen":
			include('nutzungsbedingungen.php');
			break;
		case "Registrieren":
			include('registration.php');
			break;
		case "Forum":
			include('forum/forum.php');
			break;
		case "News":
			include('news/news.php');
			break;
		case "NewsAdd":
			include('news/post_news.php');
			break;
		case "Comments":
			include('news/comments.php');
			break;
		case "CommentsEdit":
			include('news/edit_comments.php');
			break;
		case "Cats":
			include('news/cats.php');
			break;
		case "Profil":
			include('profil/profil.php');
			break;
		case "Administration":
			include('admin/admin.php');
			break;
		case "Datenschutz":
			include('datenschutz.php');
			break;
		case "Impressum":
			include('impressum.php');
			break;
		case "FAQ":
			include('faq.php');
			break;
        case "Support":
			include('support.php');
			break;		
		}
} 
//guest//
else if($rightId == 2)
{
	if(isset($_GET['site']) && ($_GET['site'] != 'Home' && $_GET['site'] != 'Nutzungsbedingungen' && $_GET['site'] != 'Registrieren' && $_GET['site'] != 'Profil' && $_GET['site'] != 'Forum' && $_GET['site'] != 'News' && $_GET['site'] != 'Comments' && $_GET['site'] != 'Datenschutz' && $_GET['site'] != 'Impressum' && $_GET['site'] != 'FAQ' && $_GET['site'] != 'Support')){
		include('errorPage.php');	
	}
	switch ($_GET['site']) {
		case "Home":
			include('home.php');
			break;
		case "Nutzungsbedingungen":
			include('nutzungsbedingungen.php');
			break;
		case "Registrieren":
			include('registration.php');
			break;
		case "Forum":
			include('forum/forum.php');
			break;
		case "News":
			include('news/news.php');
			break;
		case "Comments":
			include('news/comments.php');
			break;
		case "Datenschutz":
			include('datenschutz.php');
			break;
		case "Impressum":
			include('impressum.php');
			break;
		case "FAQ":
			include('faq.php');
			break;
        case "Support":
			include('support.php');
			break;
		case "Profil":
			include('profil/profil.php');
			break;	
		}
}
//registred//
else if($rightId == 3)
{
	if(isset($_GET['site']) && ($_GET['site'] != 'Home' && $_GET['site'] != 'Nutzungsbedingungen' && $_GET['site'] != 'Registrieren' && $_GET['site'] != 'Forum' && $_GET['site'] != 'News' && $_GET['site'] != 'Comments' && $_GET['site'] != 'CommentsEdit' && $_GET['site'] != 'Profil' && $_GET['site'] != 'Datenschutz' && $_GET['site'] != 'Impressum' && $_GET['site'] != 'FAQ' && $_GET['site'] != 'Support')){
		include('errorPage.php');	
	}
	switch ($_GET['site']) {
		case "Home":
			include('home.php');
			break;
		case "Nutzungsbedingungen":
			include('nutzungsbedingungen.php');
			break;
		case "Registrieren":
			include('registration.php');
			break;
		case "Forum":
			include('forum/forum.php');
			break;
		case "News":
			include('news/news.php');
			break;
		case "Comments":
			include('news/comments.php');
			break;
		case "Profil":
			include('profil/profil.php');
			break;
		case "CommentsEdit":
			include('news/edit_comments.php');
			break;
		case "Datenschutz":
			include('datenschutz.php');
			break;
		case "Impressum":
			include('impressum.php');
			break;
		case "FAQ":
			include('faq.php');
			break;
        case "Support":
			include('support.php');
			break;
		}
}
 ?>
	</div>
</div>
               

<div id="footer" class="container_12 footer" >

<div id="" class="grid_12 ">
	<?php include("footer.php");
	ob_end_flush();
	?>
</div>

</div>

            
</body>
</html>